/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package workers;

import entities.Statement;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import org.joda.time.LocalDate;
import preferences.Preferences;
import workers.statements.beans.CCStatementCSV;

/**
 *
 * @author bsmith
 */
public interface StatementsWorker {

    public void startup();

    /**
     * Convenience method for unit testing.  At runtime EJB Injects this.
     */
    public void setPreferences(Preferences preferences);
    
    /**
     * Lookup statements db (entityManager) given the CSV representation.  Used to check if already have the record loaded.
     * 
     * @param statementCSVItem
     * @return
     * @throws Exception 
     */
    public List<Statement> lookupStatements(CCStatementCSV statementCSVItem) throws Exception;
    
    /**
     * Retrieve the earliest date or dates if all the same.  To get just one do thelist.get(0);
     * @return List of the earliest date (ie. list of multiple items if all dates the same)
     */
    public List<Date> lookupFirstDate();// throws Exception;
    
    /**
     * From the transaction date and the statementStartMonthDay preference, calculate and build the actual date the statement that this transaction
     * belongs to.
     * @param transactionDate is the transaction date on the 'statement'
     * @return Date that is the date the statement that contains that transaction starts on
     */
    public LocalDate determineStatementNumberDate(LocalDate transactionDate);
    
    /**
     * @param firstTransactionDate - the date the first registered transaction occurred on
     * @param thisTransactionDate - date of the transaction we are interested in
     * @return the statement number, given that the firstTransaction (registered) would be on statement number 1 and a statement goes for 1 month starting on preferences.getStatementStartMonthDay().
     */
    public int determineStatementNumber(LocalDate firstTransactionDate, LocalDate thisTransactionDate);
}
